<template>
	<view class="container">
		<nav-bars class="i_top" bgColor="#fff" fontColor="#000" backState="1000">
			<view class="i_tCan" slot="default">
				<view class="i_tInput">
					<view class="i_tIcon iconfont icon-search"></view>
					<input type="text" confirm-type="search" v-model="keyword" @confirm="searchData" placeholder="搜索订单信息"
						placeholder-class="placeholder" />
				</view>
			</view>
		</nav-bars>
		<view class="nar-bar">
			<view class="tabs">
				<u-tabs
				name="cate_name" 
				count="cate_count" 
				:list="list" 
				:is-scroll="false" 
				:current="current" 
				@change="change"
				bg-color="rgba(0,0,0,0)"
				active-color="#333" 
				inactive-color="#606266"
				bar-width="60"></u-tabs>
			</view>	
		</view>
		
		<view class="content" v-if="orderList.length">
			<view class="detail" v-for="(item,index) in orderList" :key="index">
				<!-- 申述单 -->
				<view class="detail-content" v-if="current==5">
					<view class="product df-bt appealTag">
						<view class="product-info df-ct" @click="toDetail(item)">
							<view class="name">
								<view class="name-top">{{item.partner_name}}<i class="iconfont icon-more"></i></view>
								<view class="phone">订单编号：{{item.order_no}}</view>
							</view>
						</view>
						<!-- <view class="g_icon iconfont iconhuaban74" @tap.stop="callPhone(item.designer_phone)"> -->
						<view class="tag">
							<text class="platform" v-if="item.is_platform==1">平台介入</text>
							<text>{{appealStatus[item.status]}}</text>
						</view>
					</view>
					<view class="top df-bt" style="padding: 28rpx;">
						<!-- <view class="appeal">订单编号：{{item.order_no}}</view> -->
						<view class="appeal">申诉类型：{{item.appeal_type}}</view>
						<view class="appeal">
							备注内容：
							<view class="imgBox">
								<text>{{item.appeal_desc}}</text>
							</view>
						</view>
					</view>
					<view class="btn-box clearfix">
						<view>
							<view class="price-box">
								<text class="all-price">合同金额 ¥ {{item.order_amount}} </text>
							</view>
							<!-- <view class="price-box" v-if="item.is_many_way==1">
								<text class="all-price">已付定金 ¥ {{item.deposit_price}} </text>
								<text class="d-price">已付尾款 ¥{{item.balance_price}}</text>
							</view> -->
							<view class="btn">
								<text class="btn-text ssActive" @tap="toTelPhone(item.partner_phone)">联系施工队</text>
								<text class="btn-text ssActive" v-if="item.is_platform==0 && item.status!=3 && item.status!=2" @tap="toIntervene(item.id)">平台介入</text>
								<text class="btn-text ssActive" @tap="appealDetail(item.id,item.order_id)">查看详情</text>
								<text class="btn-text ssActive" v-if="item.status!=3 && item.status!=2" @click="toWithdraw(item.id)">撤回申诉</text>
							</view>
						</view>
					</view>
				</view>
				<!-- 正常单 -->
				<view class="detail-content" v-else>
					<view class="is_back" v-if="item.is_back==1">已回退</view>
					<view class="product df-bt">
						<view class="product-info df-ct">
							<!-- <image :src="item.avatar.path?item.avatar.path:''" mode="" class="product-img"></image> -->
							<view class="name">
								<view class="name-top">{{item.team_name}}<i class="iconfont icon-more"></i></view>
								<view class="phone">订单编号：{{item.order_no}}</view>
							</view>
							 <view class="item-status">{{status[item.status]}}</view>
						</view>
						<view class="iconfont icon-dadianhua" @click="toTelPhone(item.team_phone)"></view>						
					</view>
					<!-- <view class="top df-bt" v-if="item.status==1||item.status==2">
						<view class="size">
							<view class="left">
								<view class="t">下单时间</view>
								<view>{{item.create_time | dateformat('YYYY-MM-DD HH:mm:ss')}}</view>
							</view>
							<view class="right">
								<view class="tr">订单编号</view>
								<view>{{item.order_no}}</view>
							</view>
						</view>
					</view> -->
					<view class="top" v-if="item.status != 1 && item.status != 2">
						<view class="size df-bt">
							<view class="">
								<view class="t">户型</view>
								<view>{{item.house_type}}</view>
							</view>
							<view class="">
								<view class="t">面积</view>
								<view>{{item.house_area}}m²</view>
							</view>
							<view class="right">
								<view class="t">小区</view>
								<view>{{item.estate}}</view>
							</view>
						</view>
						<!-- <view class="time df-bt">
							<view class="left">
								<view class="t">下单时间</view>
								<view>{{item.create_time | dateformat('YYYY-MM-DD HH:mm:ss')}}</view>
							</view>
							<view class="right">
								<view class="tr">订单编号</view>
								<view>{{item.order_no}}</view>
							</view>
						</view> -->
						<view class="time2 df-bt">
							<view class="left">
								<view class="t">开始时间</view>
								<view>{{$utils.getFormatDate(item.build_start_time*1000,'yyyy/MM/dd hh:mm')}}</view>
							</view>
							<view class="right">
								<view class="tr">完工时间</view>
								<view>{{$utils.getFormatDate(item.build_end_time*1000,'yyyy/MM/dd hh:mm')}}</view>
							</view>
						</view>
						
					</view>
					
					<view class="btn-box clearfix">	
						<template  v-if="item.status==1">
							<view class="btn">
								<text class="btn-text" @tap="closeOrder(item.id)">关闭订单</text>
								<!-- #ifndef MP-WEIXIN -->
								<text class="btn-text" @tap="toTelPhone(item.team_phone)">联系施工队</text>
								<!-- #endif -->
								<!-- #ifdef MP-WEIXIN -->
								<text class="btn-text" v-if="!item.config_id && !item.config_url" @tap="toTelPhone(item.team_phone)">联系施工队</text>
								<text class="btn-text" v-else @click="gitpouchatshow(item.config_id,item.config_url)">联系施工队</text>
								<!-- #endif -->
							</view>
						</template>
						<template v-if="item.status==2">
							<view class="btn">
								<text class="btn-text" @click="closeOrder(item.id)">关闭订单</text>
								<!-- #ifndef MP-WEIXIN -->
								<text class="btn-text" @tap="toTelPhone(item.team_phone)">联系施工队</text>
								<!-- #endif -->
								<!-- #ifdef MP-WEIXIN -->
								<text class="btn-text" v-if="!item.config_id && !item.config_url" @tap="toTelPhone(item.team_phone)">联系施工队</text>
								<text class="btn-text" v-else @click="gitpouchatshow(item.config_id,item.config_url)">联系施工队</text>
								<!-- #endif -->
							</view>	
						</template>
						<template v-if="item.status==3">
							<view class="price-box">
								<text class="all-price">合同金额 ¥ {{item.contract_price}} </text>
								<!-- <text class="d-price" v-if="item.is_many_way==1">待付定金 ¥{{item.deposit_price}}</text> -->
							</view>
							<view class="moreBtn">
								<view class="more">
									<view @click="openMore(index)">更多</view>
									<view class="moreItem"  v-if="index==disIndex && dis">
										<view class="" @click="closeOrder(item.id)">关闭订单</view>
										<i class="iconfont">&#xe600;</i>
									</view>
								</view>
								<view class="btn">
									<text class="btn-text" @tap="handleDetail(item.id)">查看详情</text>
									<!-- #ifndef MP-WEIXIN -->
									<text class="btn-text" @tap="toTelPhone(item.team_phone)">联系施工队</text>
									<!-- #endif -->
									<!-- #ifdef MP-WEIXIN -->
									<text class="btn-text" v-if="!item.config_id && !item.config_url" @tap="toTelPhone(item.team_phone)">联系施工队</text>
									<text class="btn-text" v-else @click="gitpouchatshow(item.config_id,item.config_url)">联系施工队</text>
									<!-- #endif -->
									<!-- <text class="btn-text active" @tap="toPay(item.order_no,item.id)">付款</text> -->
								</view>
							</view>
						</template>
						<template v-if="item.status==4">
							<view class="price-box">
								<text class="all-price">合同金额 ¥ {{item.contract_price}} </text>
							</view>
							<!-- <view class="price-box" v-if="item.is_many_way==1">
								<text class="all-price">已付定金 ¥ {{item.deposit_price}} </text>
								<text class="d-price">待付尾款 ¥{{item.balance_price}}</text>
							</view> -->
							<view class="moreBtn">
								<view class="more">
									<view @click="openMore(index)">更多</view>
									<view class="moreItem" style="bottom: -324rpx;" v-if="index==disIndex && dis">
										<view class="" @click="toProgress(item.id,item.team_id)">施工进度</view>
										<!-- <view class="" @click="toMonitor(item.id,item.team_id)">远程监控</view> -->
										<view class="" @click="toBroad(item.id,item.team_id)">施工播报</view>
										<view class="" @click="toArchReta(item.id,item.team_id)">档案留存</view>
										<view class="" @click="toBackOrder(item.id)">回退</view>
										<i class="iconfont">&#xe600;</i>
									</view>
								</view>
								<view class="btn">
									<text class="btn-text" @tap="handleDetail(item.id)">查看详情</text>
									<!-- #ifndef MP-WEIXIN -->
									<text class="btn-text" @tap="toTelPhone(item.team_phone)">联系施工队</text>
									<!-- #endif -->
									<!-- #ifdef MP-WEIXIN -->
									<text class="btn-text" v-if="!item.config_id && !item.config_url" @tap="toTelPhone(item.team_phone)">联系施工队</text>
									<text class="btn-text" v-else @click="gitpouchatshow(item.config_id,item.config_url)">联系施工队</text>
									<!-- #endif -->
									<!-- <text class="btn-text active" v-if="item.is_many_way==1" @tap="toPay(item.order_no,item.id)">付款</text> -->
									<text class="btn-text active" v-if="item.pay_status==1" @click="toConfirm(item.id)">确认完工</text>
								</view>	
							</view>
						</template>
						<template v-if="item.status==5">
							<view class="price-box">
								<text class="all-price">合同金额 ¥ {{item.contract_price}} </text>
							</view>
							<!-- <view class="price-box" v-if="item.is_many_way==1">
								<text class="all-price">已付定金 ¥ {{item.deposit_price}} </text>
								<text class="d-price">已付尾款 ¥{{item.balance_price}}</text>
							</view> -->
							<view class="moreBtn">
								<view class="more">
									<view @click="openMore(index)">更多</view>
									<view class="moreItem" :style="item.is_appeal==0?'bottom: -410rpx;':'bottom: -330rpx;'" v-if="index==disIndex && dis">
										<view class="" v-if="item.is_appeal==0" @click="toAppealAdd(item)">申诉</view>
										<view class="" @click="toProgress(item.id,item.team_id)">施工进度</view>
										<!-- <view class="" @click="toMonitor(item.id,item.team_id)">远程监控</view> -->
										<view class="" @click="toBroad(item.id,item.team_id)">施工播报</view>
										<view class="" @click="toArchReta(item.id,item.team_id)">档案留存</view>
										<view class="" @click="toDel_order(item.id)">删除订单</view>
										<i class="iconfont">&#xe600;</i>
									</view>
								</view>
								<view class="btn">
									<text class="btn-text" @tap="handleDetail(item.id)">查看详情</text>
									<!-- #ifndef MP-WEIXIN -->
									<text class="btn-text" @tap="toTelPhone(item.team_phone)">联系施工队</text>
									<!-- #endif -->
									<!-- #ifdef MP-WEIXIN -->
									<text class="btn-text" v-if="!item.config_id && !item.config_url" @tap="toTelPhone(item.team_phone)">联系施工队</text>
									<text class="btn-text" v-else @click="gitpouchatshow(item.config_id,item.config_url)">联系施工队</text>
									<!-- #endif -->
									<text class="btn-text active" v-if="item.is_comment==0" @tap="toEvaluatae(item)">立即评价</text>
								</view>	
							</view>
						</template>
						<template v-if="item.status==0">
							<view class="price-box">
								<text class="all-price">合同定金 ¥ {{item.contract_price}} </text>
								<!-- <text class="d-price" v-if="item.is_many_way==1">待付定金 ¥{{item.deposit_price}}</text> -->
							</view>
							<view class="btn">
								<text class="btn-text" @tap="handleDetail(item.id)">查看详情</text>
								<text class="btn-text" @tap="toDel_order(item.id)">删除订单</text>
								<!-- #ifndef MP-WEIXIN -->
								<text class="btn-text" @tap="toTelPhone(item.team_phone)">联系施工队</text>
								<!-- #endif -->
								<!-- #ifdef MP-WEIXIN -->
								<text class="btn-text" v-if="!item.config_id && !item.config_url" @tap="toTelPhone(item.team_phone)">联系施工队</text>
								<text class="btn-text" v-else @click="gitpouchatshow(item.config_id,item.config_url)">联系施工队</text>
								<!-- #endif -->
							</view>
						</template>
					</view>
				</view>
			</view>
			<u-loadmore :status="statusLoading" :icon-type="iconType" :load-text="loadText" />
		</view>
		
		<!-- 空空如也 -->
		<view class="notList" v-else>
			<image :src="`${baseimg}/static/constr/notList.png`" mode=""></image>
			空空如也
		</view>	
		
		<!-- 二维码 -->
		<view class="qrcodepop" :style="showModal?'':'display:none;'">
			<view class="qrcodecont">
				<view class="qrname">
					<view>核销二维码</view>
					<view><canvas  canvas-id="myQrcode"></canvas></view>
				</view>
				<view class="iconfont icon-close" @click="handleHideCodeClick"></view>
			</view>
		</view>
		<!-- 微信客服 -->
		<view class="pouchat" v-if="pouchatshow">
		  <view class="poucont">	
			<view class="chatlist">
				<view class="chatml" @click="gitwxchat()" v-if="config_url">
					<image src="https://manager.ryz1620.com/static/my/wxchat.png" mode="widthFix"></image>
					<text class="t1">在线微信客服</text>
					<text class="t2">可直接联系客服</text>
				</view>
				<view class="chatml" v-if="config_id">
					<cell class="cell-service" bind:startmessage='startmessage' bind:completemessage="completemessage" :plugid="config_id"/>
					<image src="https://manager.ryz1620.com/static/my/codechat.png" mode="widthFix"></image>
					<text class="t1">添加微信客服</text>
					<text class="t2">扫微信二维码</text>
				</view>
			</view>
			<view class="iconfont icon-close" @click="wxCodeClick"></view>
		  </view>	
		</view>
	</view>
</template>

<script>
	import service_constr from '@/service/constr.js'
	import service_mall from '@/service/mall.js'
	const qrCode = require('@/utils/weapp-qrcode.js')
	export default {
		data() {
			return {
				statusLoading: 'loadmore',
				iconType: 'flower',
				loadText: {
					loadmore: '轻轻上拉',
					loading: '努力加载中',
					nomore: '实在没有了~'
				},
				status: {
					1: "待接单",
					2: "待处理",
					3: "待付款",
					4: "施工中",
					5: "已完成",
					0: "已关闭"
				},
				list: [
						{
							cate_name: '待接单',
							cate_id:1
						}, {
							cate_name: '待处理',
							cate_id:2
						}, {
							cate_name: '待付款',
							cate_id:3
						},{
							cate_name: '施工中',
							cate_id:4
						}, {
							cate_name: '已完成',
							cate_id:5
						}, {
							cate_name: '申诉单',
							cate_id:''
						},
					],
					
				// 申述订单状态
				appealStatus:{
					0: "待处理",
					1: "处理中",
					2: "已解决",
					3: "已撤回"
				},
				current: 0,
				baseimg:this.$static,
				orderList:[],
				navStatus:1,
				keyword:'',
				page:1,
				pagesize:10,
				disIndex:null, //打开更多
				dis:false,
				showModal:false,
				QrCode:'',
				terminal:"",
				config_id:'',
				config_url:'',
				pouchatshow:false,
			};
		},
		onLoad(options) {
			this.$utils.getUrl()
			this.navStatus = options.status?options.status:1
			this.current = options.status?options.status-1:0
			this.getStaffOrder()
			//#ifdef MP-WEIXIN
				this.terminal = "wxapplet";
			//#endif
		},
		onShow() {
			if(this.current==5){
				this.getAppealList()
			}else{
				this.getStaffOrder()
			}
		},
		onReachBottom() {
			this.page++
			this.statusLoading = 'loading'
			if(this.current==5){
				let params = {
					page:this.page,
					pagesize:this.pagesize
				}
				service_constr.getAppealList(params).then(res=>{
					console.log(res,'申述列表')
					if(res.code==1){
						if(!res.data.length){
							this.statusLoading = 'nomore'
						}else{
							this.statusLoading = 'loading'
						}
						this.orderList = this.orderList.concat(res.data)
					}else{
						this.orderList = []
					}
				})
			}else{
				let team_id = this.$store.state.index.sid
				let params = {
					team_id,
					status:this.navStatus==6?0:this.navStatus,
					keyword:this.keyword,
					page:this.page,
					pagesize:this.pagesize
				}
				service_constr.getStaffOrder(params).then(res=>{
					if(res.code==1){
						if(!res.data.length){
							this.statusLoading = 'nomore'
						}else{
							this.statusLoading = 'loading'
						}
						this.orderList = this.orderList.concat(res.data)
					}else{
						this.orderList = []
					}
				})
			}
		},
		components: {
		 // #ifdef MP-WEIXIN
		 			"cell": "plugin://contactPlugin/cell",
		 // #endif 
		 },
		onHide() {
			this.dis = false
		},
		methods:{
			gitpouchatshow(config_id,config_url){
				this.config_id = config_id,
				this.config_url = config_url,
				this.pouchatshow = true
			},
			wxCodeClick(){
				this.config_id = '',
				this.config_url = '',
				this.pouchatshow = false
			},
			gitwxchat(){
				wx.openCustomerServiceChat({
				  extInfo: {url: this.config_url},
				  corpId: this.$env.CORPID,
				  success(res) {}
				})
			},
			// 获取订单列表
			getStaffOrder(){
				this.page=1
				uni.showLoading({
					title:'加载中...'
				})
				// let team_id = this.$store.state.index.sid
				let params = {
					// team_id,
					status:this.navStatus==6?0:this.navStatus,
					keyword:this.keyword,
					page:this.page,
					pagesize:this.pagesize
				}
				service_constr.getStaffOrder(params).then(res=>{
					if(res.code==1){
						console.log(res)
						if(res.data.length<10){
							this.statusLoading = 'nomore'
						}
						this.orderList = res.data?res.data:[]
					}else{
						this.orderList = []
					}
				})
				uni.hideLoading()
			},
			
			// 获取申述订单列表
			getAppealList(){
				this.page=1
				uni.showLoading({
					title:'加载中...'
				})
				let params = {
					page:this.page,
					pagesize:this.pagesize
				}
				service_constr.getAppealList(params).then(res=>{
					console.log(res,'申述列表')
					if(res.code==1){
						console.log(res)
						if(res.data.length<10){
							this.statusLoading = 'nomore'
						}
						this.orderList = res.data?res.data:[]
					}else{
						this.orderList = []
					}
				})
				uni.hideLoading()
			},
			
			// 搜索
			searchData(){
				this.getStaffOrder()
			},
			
			// 申诉按钮
			toAppealAdd(item){
				let params = encodeURIComponent(JSON.stringify(item))
				uni.navigateTo({
					url:'/pages_decoration/pages/appealAdd/add?data='+params+'&orderType=builder'
				})
			},
			
			// 申述订单跳转详情
			appealDetail(id,order_id){
				uni.navigateTo({
					url: '/pages_two/pages/order/detail?order_id=' + order_id + '&appeal_id=' + id
				})
			},
			
			// 平台介入按钮
			toIntervene(id){
				uni.showModal({
					title:'确定平台介入该申诉吗？',
					success:res=>{
						if(res.confirm){
							let params = {
								appeal_id:id
							}
							service_constr.toIntervene(params).then(res=>{
								if(res.code==1){
									uni.showToast({
										title:'平台介入成功',
										icon:'success'
									})
									this.orderList = []
									this.getAppealList()
								}else{
									uni.showToast({
										title:res.msg,
										icon:'none'
									})
								}
							})
						}
					}
				})
			},
			
			// 撤回申诉按钮
			toWithdraw(id){
				uni.showModal({
					title:'确定撤回该申诉吗？',
					success:res=>{
						if(res.confirm){
							let params = {
								appeal_id:id
							}
							service_constr.toWithdraw(params).then(res=>{
								if(res.code==1){
									uni.showToast({
										title:'撤回成功',
										icon:'success'
									})
									this.orderList = []
									this.getAppealList()
								}else{
									uni.showToast({
										title:res.msg,
										icon:'none'
									})
								}
							})
						}
					}
				})
			},
			
			// 回退按钮
			toBackOrder(id){
				let that = this
				uni.showModal({
					content:'确定回退该订单吗？',
					success:res=>{
						if(res.confirm){
							let params = {
								order_id:id,
								is_back:1
							}
							service_constr.toBackOrder(params).then(res=>{
								console.log(res,'回退结果')
								if(res.code==1){
									uni.showToast({
										title:'回退成功',
										icon:'success'
									})
									this.dis = false
									setTimeout(function(){that.getStaffOrder()},500)
								}else{
									uni.showToast({
										title:res.msg,
										icon:'none'
									})
								}
							})
						}
					}
				})
			},
			
			// 确认完工按钮
			toConfirm(id){
				let that = this
				uni.showModal({
					content:'是否确定满意完工？',
					success:res=>{
						if(res.confirm){
							service_constr.confirmOrder({order_id:id}).then(res=>{
								console.log(res,'确定完工')
								if(res.code==1){
									uni.showToast({
										title:'已确定完工',
										icon:'success'
									})
									setTimeout(function(){
										that.getStaffOrder()
									},300)
								}else{
									uni.showToast({
										title:res.msg,
										icon:'none'
									})
								}
							})
						}
					}
				})
			},
			
			// 立即评价按钮
			toEvaluatae(item){
				
				if(item.team_id){
					uni.navigateTo({
						url:'/pages_two/pages/construction/evaluate/add?teamId=' + item.team_id + '&decorationId=' + item.decoration_id + '&name=' + item.team_name + '&orderId=' + item.id
					})
				}else{
					uni.navigateTo({
						url:'/pages_two/pages/construction/evaluate/add?decorationId=' + item.decoration_id + '&teamId=' + item.team_id + '&name=' + item.team_name + '&orderId=' + item.id
					})
				}
			},
			
			toBack() {
			  	uni.navigateBack({
			  	    delta: 1
			  	});
			  },
			change(index) {
				console.log(index)
				this.current = index;
				this.dis = false
				this.navStatus = this.list[index].cate_id
				if(index==5){
					this.getAppealList()
				}else{
					this.getStaffOrder()
				}
				
				// if(this.navStatus==6){  //取消与关闭数据合并到一起
				// 	let team_id = this.$store.state.index.sid
				// 	let params = {
				// 		team_id,
				// 		status:0,
				// 		keyword:this.keyword
				// 	}
				// 	service_constr.getStaffOrder(params).then(res=>{
				// 		if(res.code==1){
				// 			console.log(res)
				// 			this.orderList.concat(res.data?res.data:[])
				// 		}
				// 	})
				// }
			},
			
			// 电话按钮
			toTelPhone(phone){
				console.log(phone,'电话电话')
				uni.makePhoneCall({
				 	// 手机号
				    phoneNumber:phone, 
					// 成功回调
					success: (res) => {
						console.log('调用成功!')	
					},
					// 失败回调
					fail: (res) => {
						console.log('调用失败!')
					}
				});
			},
			
			// 接单
			 handleOrder(id){
				 service_constr.toAccept({id}).then(res=>{
					 if(res.code==1){
						this.getStaffOrder()
						uni.navigateTo({
							url:`/pagesOne/constr/home/order/order?id=${id}`
						})
						uni.showToast({
							title:'接单成功'
						})
					 }else{
						 uni.showToast({
						 	title:res.msg,
							icon:'none'
						 })
					 }
				 })
				 
			 },
			 
			 // 取消订单
			 closeOrder(id){
				 // this.show = true
				 uni.showModal({
				 	content:'确定要关闭当前订单吗？',
					success:res=>{
						if(res.confirm){
							service_constr.cancelOrder({order_id:id}).then(res=>{
								if(res.code==1){
									this.getStaffOrder()
									this.dis = false
									uni.showToast({
										title:'已关闭',
										icon:'success'
									})
								}else{
									uni.showToast({
										title:res.msg,
										icon:'none'
									})
								}
							}) 
						}
					}
				 })
			 },
			 
			 // 进入施工进度
			 progress(id){
				 console.log(id)
				uni.navigateTo({
					url:`../../progress/progressList?order_id=${id}`
				}) 
			 },
			 
			 // 关闭订单
			 handleAmend(id){
				 uni.showModal({
				 	content:'确定要关闭当前订单吗？',
				 	success:res=>{
				 		if(res.confirm){
				 			service_constr.cancelOrder({id}).then(res=>{
				 				if(res.code==1){
				 					this.getStaffOrder()
									this.dis = false
				 					uni.showToast({
				 						title:'已关闭',
				 						icon:'success'
				 					})
				 				}else{
				 					uni.showToast({
				 						title:res.msg,
				 						icon:'none'
				 					})
				 				}
				 			}) 
				 		}
				 	}
				 })
			 },
			 
			 // 取消订单弹框中确定
			 toCancel(id){
				 
			 },
			 
			 // 删除订单
			 toDel_order(id){
				uni.showModal({
					content: '确定删除该订单吗？',
					success: res => {
						if(res.confirm){
							service_constr.delOrder({order_id:id}).then(res=>{
								console.log(res,'删除订单结果')
								if(res.code==1){
									this.getStaffOrder()
									this.dis = false
									uni.showToast({
										title:'删除成功',
										icon:'success'
									})
								}else{
									uni.showToast({
										title:res.msg,
										icon:'none'
									})
								}
							})
						}
					},
				});
			 },
			 
			 // 打开更多
			 openMore(index){
				 this.disIndex = index
				if(this.dis){
					this.dis = false
				}else{
					this.dis = true
				}
			 },
			 
			 // 进入档案留存
			toArchReta(id,team_id){
				uni.navigateTo({
					url:`/pages_two/pages/construction/broadcast/broadcast?order_id=${id}&team_id=${team_id}&tabName=档案留存`
				})
			},
			
			// 进入施工播报
			toBroad(id,team_id){
				uni.navigateTo({
					url:`/pages_two/pages/construction/broadcast/broadcast?order_id=${id}&team_id=${team_id}&tabName=施工播报`
				})
			},
			
			// 进入远程监控
			toMonitor(id,team_id){
				uni.navigateTo({
					url:`/pages_two/pages/construction/broadcast/broadcast?order_id=${id}&team_id=${team_id}&tabName=远程监控`
				})
			},
			// 进入施工进度
			toProgress(id,team_id){
				uni.navigateTo({
					url:`/pages_two/pages/construction/broadcast/broadcast?order_id=${id}&team_id=${team_id}&tabName=施工节点`
				})
			},
			 
			 handleSure(event){
				 let params = {
					 id:event
				 }
				 this.$api.designerOrder_complete(params).then(res=>{
					 if(res.code==1){
						alert('订单已完成')
					 }
				 })
				 
			 },
			 
			 handleDelete(id){
				 // this.show4 = true
				 uni.showModal({
				 	content:'确定要删除此订单吗？',
					success:res=>{
						if(res.confirm){
							service_constr.delOrder({id}).then(res=>{
								if(res.code==1){
									this.getStaffOrder();
									this.dis = false
									uni.showToast({
										title:'删除成功',
										icon:'success'
									})
								}
							}) 
						}
					}
				 })
			 },
			 
			 initQrCode:function(){
			 	new qrCode('myQrcode', {
			 		text: this.QrCode,
			 		width: 160,
			 		height: 160,
			 		colorDark: "#333333",
			 		colorLight: "#FFFFFF",
			 		correctLevel: qrCode.CorrectLevel.H
			 	})
			 },
			 
			 // 核销二维码
			 handleShowCodeClick:function(){
			 	this.showModal = true
			 	this.$nextTick(function(){
			 		this.initQrCode()
			 	})
			 },
			 handleHideCodeClick:function(){
			 	this.showModal = false
			 },
			 
			 // 支付按钮
			 toPay(order_no,order_id){
			 	let itemList = [ "微信支付", "线下支付"]
			 	this.itemList = itemList
			 	uni.showActionSheet({
			 	    itemList: this.itemList,
			 	    success: (t) => {
			 			this.tapIndex = t.tapIndex+1
			 			this.getpayorder(order_no,order_id)
			 		}
			 	});
			 },
			 
			 getpayorder(order_codes,order_id){
			 	service_mall.getpay({
			 		order_no:order_codes,
			 		type:'builder_order',
			 		pay_type:this.tapIndex
			 		}).then(res=>{
			 		if(res.code == 1){
			 			let data = res.data
			 		    if(this.tapIndex == 1){	
			 				if(this.terminal == 'wxapplet'){
			 					uni.requestPayment({
			 						appId:res.data.appId,
			 						nonceStr: res.data.nonceStr,
			 						package: res.data.package,
			 						paySign: res.data.paySign,
			 						signType: res.data.signType,
			 						timeStamp: res.data.timeStamp,
			 						success: (suc) => {
			 							uni.navigateTo({
			 								url: `/pages_two/pages/construction/order/sucess?type=1&order_id=${order_id}$order_code=${order_codes}`
			 							})
			 						},
			 						fail: (err) => {
			 							uni.navigateTo({
			 								url: `/pages_two/pages/construction/order/sucess?type=0&order_id=${order_id}$order_code=${order_codes}`
			 							})
			 						}
			 					});
			 				}else{
			 					uni.requestPayment({
			 						provider: 'wxpay',
			 						orderInfo: {
			 							"appid":res.data.appid,
			 							"partnerid": res.data.partnerid,
			 							"prepayid": res.data.prepayid,
			 							"noncestr": res.data.noncestr,
			 							"package": res.data.package,
			 							"timestamp": res.data.timestamp,
			 							"sign": res.data.sign,
			 						},
			 						success: (suc) => {
			 							uni.navigateTo({
			 								url: `/pages_two/pages/construction/order/sucess?type=1&order_id=${order_id}$order_code=${order_codes}`
			 							})
			 						},
			 						fail: (err) => {
			 							console.log(err,12345)
			 							uni.navigateTo({
			 								url: `/pages_two/pages/construction/order/sucess?type=0&order_id=${order_id}$order_code=${order_codes}`
			 							})
			 						}
			 					});
			 				}
			 			}else{
			 				this.QrCode = res.data.verificationCode
			 				this.handleShowCodeClick()
			 			}
			 							
			 		}else{
			 				this.failMsg(res)
			 		}	
			 	})
			 },
			 
			 handleDispose(event){
				let id = event
				 uni.navigateTo({
				 	url:`/pagesOne/constr/home/order/dispose?id=${id}`
				 })
			 },
			 handleDetail(event){
				 let id = event				 
				 uni.navigateTo({
				 	url:`/pages_two/pages/order/detail?order_id=${id}`
				 })
			 },
			 handleDelivery(event){
				  let id = event
				 uni.navigateTo({
				 	url:`/pagesOne/constr/home/order/delivery?id=${id}`
				 })
			 },
			 handleAccomplish(event){
				 let id = event
				 uni.navigateTo({
				 	url:`/pagesOne/constr/home/order/accomplish?id=${id}`
				 })
			 },
			 hanldeClose(event){
				 let id = event
				 uni.navigateTo({
				 	url:`/pagesOne/constr/home/order/close?id=${id}`
				 })
			 },
		}
	}
</script>

<style lang="less" scoped>
	@import  '../iconfont.css';
	.container{
	   height: 100%;
	   // 导航栏
	   .s_navBar {position: absolute;top: 0;left: 0; z-index: 10;
	   	.s_nCenter {width: 100%;}
	   	.s_nBg {width: 100vw;background: rgba(255,255,255,0.1);position: fixed;top: 0;left: 0;z-index: -1;filter: blur(1px);}
	   	.s_nInput {color: #939393;width: 400rpx;height: 66rpx;border: 2rpx solid rgba(255,255,255,0.5); background: rgba(255,255,255,0.1);padding: 0 64rpx;border-radius: 36rpx;position: relative;
	   		& > input {height: 100%;font-size: 24rpx;}
	   	}
	   	.s_nIcon {width: 28rpx;height: 28rpx;line-height: 28rpx;color: #939393;font-size: 28rpx;position: absolute;top: 50%;left: 28rpx;margin-top: -14rpx;}
	   }
	.nar-bar{
		z-index: 1;
		height: 80rpx;
		width: 100%;
		background: #fff;
		.icon-fanhui{
			color: #333;
			font-size: 38rpx;
			margin-right: 35rpx;
		}
		.search-box {
			width: 100%;
			display: flex;
			align-items: center;
			padding: 0 28rpx;
			padding-top: 50rpx;
		}
		.search{
			display: flex;
			align-items: center;
			justify-content: space-between;
			width: 422rpx;
			height: 66rpx;
			border: 1px solid #FFFFFF;
			opacity: 0.5;
			// background: rgba(52,58,66,.5);
			border-radius: 34rpx;
			input{
				width: 82%;
				height: 100%;
				color: #FFFFFF;
			}
			.icon-sousuo{
				color: #FFFFFF;
				margin-left: 28rpx;
				
			}
		}
		.tabs{
			width: 100%;
			// margin-top: 55rpx;
		}
	}
	.content{
		// padding: 40rpx 24rpx;
		.detail{
			padding: 0rpx 24rpx;
			margin-top: 20rpx;
			.detail-content{
				background-color: #fff;
				padding: 40rpx 24rpx;
				margin-bottom: 22rpx;
				border-radius: 16rpx;
				position: relative;
				.is_back{
					position: absolute;
					top: 0;
					right: 0;
					width: 90rpx;
					height: 36rpx;
					background-color: #E7AD14;
					border-radius: 0 16rpx 0 16rpx;
					font: 400 22rpx/36rpx PingFang SC;
					text-align: center;
					color: #fff;
				}
				.top{
					// padding: 28rpx;
					background: #F8F8F8;
					border-radius: 8rpx;
					color: #505050;
					margin-bottom: 30rpx;
					.size{
						width: 100%;
						padding: 28rpx;
						border-bottom: 2rpx solid #fff;
						display: flex;
						align-items: center;
						justify-content: space-between;
					}
					.time{padding: 28rpx 28rpx 0;}
					.time2{padding: 28rpx;display: flex;justify-content: space-between;}
					.right{
						display: flex;
						flex-direction: column;
						justify-content: flex-end;
						text-align: right;
						// align-items: right;
						}
						.t {
							font-size: 22rpx;
							font-family: PingFang SC;
							font-weight: 400;
							line-height: 36rpx;
							color: #A0A0A0;
						}
						.tr{
							font-size: 22rpx;
							font-family: PingFang SC;
							font-weight: 400;
							line-height: 36rpx;
							color: #A0A0A0;
							text-align: right;
						}
					
					// 申诉单
					.appeal{
						font: 500 24rpx/40rpx PingFang SC;
						color: #333;
						display: flex;
						text{
							color: #A0A0A0;
						}
					}
					
				}
				.appealTag{
					display: flex;
					justify-content: space-between;
				}
				.product {
					padding-bottom: 30rpx;
					position: relative;
					.tag{
						display: flex;
						align-items: center;
						font: 500 24rpx/24rpx PingFang SC;
						color: #FFFFFF;
						text{
							background-color: #E7AD14;
							padding: 7rpx 9rpx;
							border-radius: 4rpx;
							margin-left: 12rpx;
						}
						.platform{
							background-color: #FD6260;
						}
					}
					.product-img {
						width: 84rpx;
						height: 84rpx;
						border-radius: 50%;
						margin-right: 20rpx;
					}
					
					.product-info{
						display: flex;
						justify-content: space-between;
					}
					.name{
						.name-top{
							font-size: 28rpx;
							font-weight: 600;
							line-height: 40rpx;
							color: #333;
							display: flex;
							align-items: center;
							.iconfont{font-size: 20rpx;}
						}
						.phone{
							font-size: 22rpx;
							font-weight: 400;
							line-height: 40rpx;
							color: #A0A0A0;
						}
					}
					.item-status{
						font: 400 24rpx/44rpx PingFang SC;
						color: #939393;
					}
					
				}
				
				.btn-box {
					&:after { display: block; clear: both; content: ''; visibility: hidden; height: 0; }
					.more {
						float: left;
						font-size: 26rpx;
						font-family: PingFang SC;
						font-weight: 400;
						line-height: 40rpx;
						color: #A0A0A0;
						padding-top: 10rpx;
					}
					.price-box {
						text-align: right;
						padding: 30rpx 0 30rpx 0;
						font-size: 26rpx;
						font-family: PingFang SC;
						font-weight: 500;
						line-height: 20rpx;
						color: #878787;
						.d-price {
							color: #dfb368;
							font-size: 32rpx;
							padding-left: 20rpx;
						}
					}
					.moreBtn{
						display: flex;
						justify-content: space-between;
						position: relative;
						.more{
							position: relative;
							.moreItem{
								position: absolute;
								bottom: -82rpx;
								left: -4rpx;
								z-index: 10;
								border-radius: 8rpx;
								width: 144rpx;
								text-align: center;
								background-color: rgba(10,6,5,0.6);
								color: #fff;
								font: 400 26rpx/80rpx PingFang SC;
								
								i{
									height: 16rpx;
									color: rgba(10,6,5,0.6);
									position: absolute;
									font-size: 20rpx;
									left: 8rpx;
									top: -44rpx;
								}
							}
						}
					}
					.btn {
						// width: 50%;
						// float: right;
						display: flex;
						justify-content:flex-end ;
						align-items: center;
						.btn-text {
							width: 172rpx;
							height: 64rpx;
							background: #FFFFFF;
							border: 2rpx solid #505050;
							opacity: 1;
							border-radius: 32rpx;
							text-align: center;
							line-height: 64rpx;
							color: #505050;
							font-size: 26rpx;
							margin-left: 20rpx;
						}
						.active{
							// background-color: #DBA954;
							// color: #fff;
							// border: 0;
							border-color: #DBA954;
							color: #DBA954;
						}
					}
					
				}
			}
		}
	}
	// 没有数据
	.notList{
		position: absolute;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		margin: auto;
		height: 400rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
		width: 426rpx;
		image{
			width: 426rpx;
			height: 356rpx;
			margin-bottom: 40rpx;
		}
		font:500 40rpx/56rpx PingFang SC;
		color: #333;
	}
	// 二维码
	.qrcodepop{
		position: fixed;
		top:0;
		left: 0;
		width: 100%;
		height: 100%;
		background: rgba(0,0,0,0.2);
		z-index: 9999;
		.qrcodecont{
			width: 400rpx;
			position: absolute;
			left: 50%;
			top: 25%;
			margin-left: -200rpx;
			.qrname{
				background: #fff;
				line-height: 80rpx;
				height: 440rpx;
				overflow: hidden;
				padding: 20rpx;
				text-align: center;
				border-radius: 15rpx;
				canvas{
					width: 300rpx;
					height: 300rpx;
					margin: auto;
				}
			}
			.icon-close{
				display: block;
				font-size: 60rpx;
				color: #fff;
				text-align: center;
				margin: 30rpx auto;
			}
		}
	}	
}
// 顶部搜索框=====
	.container .i_top {
		position: relative;
		z-index: 999;
		background: #fff;
		.i_tCan {
			width: 100%;
			height: 66rpx;
			// padding-left: 32rpx;
			padding-right: 24rpx;
			/* #ifndef APP-PLUS-NVUE */
			// margin-left: 34rpx;
			width: 500rpx;
			/* #endif */
			flex: 1;
			/*#ifdef H5 || MP-WEIXIN*/
			width: 400rpx;
			/*#endif*/
		}
	
		.i_tBg {
			width: 100vw;
			height: 500rpx;
			background: linear-gradient(135deg, #2e333f 0%, #191d29 100%);
			position: fixed;
			top: 0;
			left: 0;
		}
	
		.i_tInput {
			height: 66rpx;
			border-radius: 34rpx;
			background: #F6F7FB;
			position: relative;
			opacity: .8;
	
			&>input {
				width: 100%;
				height: 100%;
				font-size: 24rpx;
				padding-left: 72rpx;
			}
		}
	
		.i_tIcon {
			width: 32rpx;
			height: 32rpx;
			line-height: 32rpx;
			color: #6c6c6c;
			font-size: 32rpx;
			position: absolute;
			top: 18rpx;
			left: 32rpx;
		}
	}
// 客服弹框
		.pouchat{
			position: fixed;
			background: rgba(0,0,0,0.5);
			top:0;
			left: 0;
			width: 100%;
			height: 100%;
			z-index: 9999;
			.poucont{
				position: absolute;
				top:30%;
				left: 15%;
				right: 15%;
				.icon-close{
					width: 80rpx;
					height: 80rpx;
					font-size: 70rpx;
					color: #fff;
					line-height: 80rpx;
					text-align: center;
					margin: 30rpx auto;
				}
			}
			.chatlist{
				background: #fff;
				padding:30rpx;
				border-radius: 10rpx;
			}
			.chatml{
				position: relative;
				padding: 20rpx;
				padding-left: 100rpx;
				min-height: 100rpx;
				.cell-service{
					position: absolute;
					right: 0;
					bottom: 0;
					left: 0;
					top: 0;
					opacity: 0;
					z-index: 10;
					.cell--bubble{
						width: 100%;
					}
				}
				text{
					display: block;
					line-height: 40rpx;
				}
				.t1{
					font-size: 32rpx;
				}
				.t2{
					font-size: 24rpx;
					color: #999;
				}
				image{
					width: 70rpx;
					height: 70rpx;
					position: absolute;
					left: 15rpx;
					top:25rpx;
				}
			}
		}	
</style>
